package com.ltmonitor.web.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;





import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ltmonitor.util.DateUtil;
import com.ltmonitor.web.util.JsonMessage;

/**
 * 部门上线率
 * 查询部门上线率数据并输出到页面，形成图标
 * @author admin
 *
 */
@Controller
@RequestMapping("/chart")
public class DepOnlineRateChartAction extends GenericAction {

	@RequestMapping("/viewDepOnlineRateChart.action")
	public String viewDepOnlineRateChart() {
		return "/chart/depOnlineRateChart";
	}
	

	@RequestMapping("/depOnlineRateChart.action")
	@ResponseBody
	public JsonMessage execute(int depId, Date chartDate) {
		try {
			Map params = new HashMap();
			params.put("depId", depId);
			String strEndDate = DateUtil.dateToString(chartDate) + " 23:59";
			params.put("startDate", DateUtil.dateToString(chartDate));
			params.put("endDate", strEndDate);
			String queryId = "selectDepartmentOnlineRate";
			List rs = this.queryService.query(queryId, params);
			return json(true, rs);
		} catch (Exception ex) {
			log.error(ex.getMessage(), ex);
			return json(false, ex.getMessage());
		}
		/**
		 * String depName=""; for(Object obj :rs) { Map rowData=(Map)obj;
		 * depName = ""+rowData.get("depName"); int hour =
		 * (Integer)rowData.get("stHour"); double rate =
		 * Double.parseDouble(""+rowData.get("onlineRate"));
		 * 
		 * }
		 */
	}


}
